<?php
class Order extends AppModel {
	var $name = 'Order';
	
	public $actsAs = array('Searchable');	
	public $filterArgs = array(
		array('name' => 'numer', 'type' => 'like'),
		array('name' => 'name', 'type' => 'like'),
		array('name' => 'payment_status', 'type' => 'value'),
		array('name' => 'status_of_implementation', 'type' => 'value'),
		array('name' => 'type_of_service_id', 'type' => 'value'),
		array('name' => 'types_of_spaces_id', 'type' => 'value')
	);	
	
	var $displayField = 'name';
	var $validate = array(
		'customer_id' => array(
			'rule' => 'notempty',
        	'message' => 'This field cannot be left blank'
		),
		'type_of_service_id' => array(
			'rule' => 'notempty',
        	'message' => 'This field cannot be left blank'
		),
		'types_of_spaces_id' => array(
			'rule' => 'notempty',
        	'message' => 'This field cannot be left blank'
		),
		'status_of_implementation' => array(
			'rule' => 'notempty',
        	'message' => 'This field cannot be left blank'
		),
		'payment_status' => array(
			'rule' => 'notempty',
        	'message' => 'This field cannot be left blank'
		),
		'value_of_the_order' => array(
			'rule' => 'notempty',
        	'message' => 'This field cannot be left blank'
		),
		'name' => array(
			'rule' => 'notempty',
        	'message' => 'This field cannot be left blank'
		),
		'date_start' => array(
			'rule' => 'notempty',
        	'message' => 'This field cannot be left blank'
		)
	);
	//The Associations below have been created with all possible keys, those that are not needed can be removed

	var $belongsTo = array(
		'Customer' => array(
			'className' => 'Customer',
			'foreignKey' => 'customer_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'TypeOfService' => array(
			'className' => 'TypeOfService',
			'foreignKey' => 'type_of_service_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'TypesOfSpaces' => array(
			'className' => 'TypesOfSpaces',
			'foreignKey' => 'types_of_spaces_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);
	
	var $hasOne = array(
		'OrdersCycle' => array(
			'className' => 'OrdersCycle',
			'foreignKey' => 'orders_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)	
	);

	var $hasMany = array(
		'OrdersBreak' => array(
			'className' => 'OrdersBreak',
			'foreignKey' => 'orders_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'OrdersSeries' => array(
			'className' => 'OrdersSeries',
			'foreignKey' => 'orders_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)		
	);
	
	var $hasAndBelongsToMany = array(
		'Employee' => array(
			'className' => 'Employee',
			'joinTable' => 'orders_employees',
			'foreignKey' => 'orders_id',
			'associationForeignKey' => 'employee_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		)
	);

}
?>